 package opbanco;
 
 import java.io.BufferedReader;
 import java.io.FileNotFoundException;
 import java.io.FileReader;
 import java.io.IOException;
 import java.io.PrintStream;
 import java.io.UnsupportedEncodingException;
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.ResultSet;
 import java.sql.SQLException;
  import java.sql.Statement;
 import java.util.Date;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
import javax.mail.Message;
 import javax.mail.Message.RecipientType;
 import javax.mail.MessagingException;
 import javax.mail.Session;
 import javax.mail.Transport;
 import javax.mail.internet.AddressException;
 import javax.mail.internet.InternetAddress;
 import javax.mail.internet.MimeMessage;
 
 public class Banco
 {
   public static Connection Conecta(String Caminho)
     throws SQLException, FileNotFoundException, IOException, ClassNotFoundException
   {
/*   31 */     FileReader clienteFile = new FileReader(Caminho);
/*   32 */     BufferedReader clienteReader = new BufferedReader(clienteFile);
/*   33 */     String Servidor = clienteReader.readLine();
/*   34 */     String Banco = clienteReader.readLine();
/*   35 */     String Usuario = clienteReader.readLine();
/*   36 */     String Senha = clienteReader.readLine();
/*   37 */     clienteReader.close();
/*   38 */     clienteFile.close();
/*   39 */     Class.forName("net.sourceforge.jtds.jdbc.Driver");
/*   40 */     return DriverManager.getConnection("jdbc:jtds:sqlserver://" + Servidor + ":1433/" + Banco, Usuario, Senha);
   }
 
   public static ResultSet Consulta(String SQL, Connection Conexao) throws SQLException
   {
/*   45 */     Statement stm = Conexao.createStatement();
/*   46 */     return stm.executeQuery(SQL);
   }
 
   public static void Operacao(String SQL, Connection Conexao) throws SQLException
   {
/*   51 */     Statement stm = Conexao.createStatement();
/*   52 */     stm.executeUpdate(SQL);
   }
 
   public static int Presenca(String Cod, String IP, String Op, String Cod_Acesso, Connection Conexao)
   {
     try {
/*   58 */       ResultSet rs = null;
/*   59 */       Operacao("delete from tb_online where datediff(n, momento, getdate()) > 20", Conexao);
/*   60 */       if (Op.equalsIgnoreCase("e")) {
/*   61 */         rs = Consulta("select * from tb_bloqueados where cd_colaborador=" + Cod, Conexao);
/*   62 */         if (rs.next()) {
/*   63 */           return 0;
         }
/*   65 */         Operacao("delete from tb_online where cd_colaborador=" + Cod, Conexao);
/*   66 */         Operacao("insert tb_online(cd_colaborador,ip_maquina,momento) values(" + Cod + ",'" + IP + "',getdate())", Conexao);
/*   67 */         rs = Consulta("select max(cd_acesso) as maximo from tb_online where cd_colaborador=" + Cod, Conexao);
/*   68 */         rs.next();
/*   69 */         return rs.getInt(1);
       }
 
/*   72 */       if (Op.equalsIgnoreCase("a")) {
/*   73 */         rs = Consulta("select cd_acesso from tb_online where cd_acesso=" + Cod_Acesso, Conexao);
/*   74 */         if (rs.next()) {
/*   75 */           Operacao("update tb_online set momento=getdate() where cd_acesso=" + Cod_Acesso, Conexao);
/*   76 */           return rs.getInt(1);
         }
/*   78 */         return 0;
       }
 
/*   81 */       if (Op.equalsIgnoreCase("s")) {
/*   82 */         Operacao("delete from tb_online where cd_acesso=" + Cod_Acesso, Conexao);
/*   83 */         return 0;
       }
/*   85 */       return 0;
     } catch (SQLException e) {
     }
/*   88 */     return 0;
   }
 
   public static boolean injection(Map parametros)
   {
/*   93 */     String parm = null;
/*   94 */     Iterator it = parametros.keySet().iterator();
/*   95 */     while (it.hasNext()) {
/*   96 */       String[] parme = (String[])parametros.get(it.next());
/*   97 */       parm = parme[0];
/*   98 */       System.out.print("Parametro " + parm);
/*   99 */       if ((parm.contains("*")) || (parm.contains("'")) || (parm.contains(";")) || (parm.contains("select")) || (parm.contains("sys")) || (parm.contains("exec")) || (parm.contains("delete")) || (parm.contains("update")) || (parm.contains("insert")) || (parm.contains("\\")) || (parm.contains("or")) || (parm.contains("''")))
       {
/*  102 */         return true;
       }
     }
/*  105 */     return false;
   }
 
   public static void Viu(String Pt, String Colab, Connection Conexao) {
     try {
/*  110 */       Operacao("delete from tb_historico where (cd_colaborador=" + Colab + " and protocolo='" + Pt + "') or (datediff(d, dt_visualizacao, getdate()) > 5)", Conexao);
 
/*  112 */       Operacao("insert into tb_historico(cd_colaborador,protocolo) values(" + Colab + ",'" + Pt + "')", Conexao);
     } catch (Exception e) {
/*  114 */       e.printStackTrace();
     }
   }
 
   public static boolean EhProcesso(String Pt, Connection Conexao)
   {
     try
     {
/*  122 */       ResultSet rs = Consulta("select protocolo from tb_processo where (len(protocolo)=5) and protocolo='" + Pt + "'", Conexao);
/*  123 */       return !rs.next(); } catch (SQLException e) {
     }
/*  125 */     return false;
   }
 
   public static boolean Fav_Aut(String Fav, String Colab, Connection Conexao)
   {
     try
     {
/*  132 */       if (Fav_Dono(Fav, Colab, Conexao)) {
/*  133 */         return true;
       }
/*  135 */       ResultSet rs = Consulta("select * from tb_favaut where altera=1 and cd_favorito=" + Fav + " and cd_colaborador=" + Colab, Conexao);
/*  136 */       return rs.next();
     } catch (SQLException e) {
     }
/*  139 */     return false;
   }
 
   public static boolean Fav_Avs(String Fav, String Colab, Connection Conexao)
   {
     try
     {
/*  146 */       if (Fav_Dono(Fav, Colab, Conexao)) {
/*  147 */         ResultSet rs = Consulta("select * from tb_favorito where aviso=1 and cd_favorito=" + Fav + " and cd_proprietario=" + Colab, Conexao);
/*  148 */         return rs.next();
       }
/*  150 */       ResultSet rs = Consulta("select * from tb_favaut where aviso=1 and cd_favorito=" + Fav + " and cd_colaborador=" + Colab, Conexao);
/*  151 */       return rs.next();
     } catch (SQLException e) {
     }
/*  154 */     return false;
   }
 
   public static void Ope_AvsFav(String Fav, String Colab, String Ope, Connection Conexao)
   {
     try
     {
/*  161 */       if (Fav_Dono(Fav, Colab, Conexao))
/*  162 */         Operacao("update Tb_Favorito set aviso=" + Ope + " where cd_favorito=" + Fav + " and cd_proprietario=" + Colab, Conexao);
       else
/*  164 */         Operacao("update Tb_Favaut set aviso=" + Ope + " where cd_favorito=" + Fav + " and cd_colaborador=" + Colab, Conexao);
     }
     catch (SQLException e) {
/*  167 */       e.printStackTrace();
     }
   }
 
   public static boolean Fav_Dono(String Fav, String Colab, Connection Conexao)
   {
     try
     {
/*  175 */       ResultSet rs = Consulta("select * from tb_favorito where cd_favorito=" + Fav + " and cd_proprietario=" + Colab, Conexao);
/*  176 */       return rs.next(); } catch (SQLException e) {
     }
/*  178 */     return false;
   }
 
   public static int Cad_Processo(String Pt, String Dt, String Tp, String Obj, String Prop, String Atd, String St, String Vl, String Usu, String Pg, String Cl, String Tr,String Ex, Connection Conexao)
   {
     try
     {
/*  186 */       if (Vl.equals("")) {
/*  187 */         Vl = "0";
       } else {
/*  189 */         Vl = Vl.replace(".", "");
/*  190 */         Vl = Vl.replace(",", ".");
       }
/*  192 */       Obj = Obj.replace("'", " ");
/*  193 */       Operacao("insert into tb_processo(protocolo,dt_protocolo,dt_entrada,cd_tipoprocesso,objeto,cd_status,cd_proponente,cd_atendido,valor,dt_tramite,cd_responsavel,cd_coresponsavel,cd_designador,cd_digitador,paginas,cd_classificacao,cd_trilho,num_externo) values('" + Pt + "','" + Dt + "',getdate()," + Tp + ",'" + Obj + "',2," + Prop + "," + Atd + "," + Vl + ",getdate()," + St + "," + Usu + "," + Usu + "," + Usu + "," + Pg + "," + Cl + "," + Tr +",'" + Ex +"')", Conexao);
 
/*  197 */       return 1; } catch (SQLException e) {
     }
/*  199 */     return 0;
   }
 
   public static int Edt_Processo(String Pt, String Dt, String Tp, String Obj, String Prop, String Atd, String Vl, String Usu, String Pg, String Cl, String Tr,String Ex, Connection Conexao)
   {
     try
     {
/*  208 */       boolean Dig = Digitador(Usu, Pt, Conexao);
/*  209 */       if (!Dig) return 0;
/*  210 */       if (Vl.equals("")) {
/*  211 */         Vl = "0";
       } else {
/*  213 */         Vl = Vl.replace(".", "");
/*  214 */         Vl = Vl.replace(",", ".");
       }
/*  216 */       Obj = Obj.replace("'", " ");
/*  217 */       Operacao("update tb_processo set dt_protocolo='" + Dt + "',cd_tipoprocesso=" + Tp + ",objeto='" + Obj + "',cd_proponente=" + Prop + ",cd_atendido=" + Atd + ",valor=" + Vl + ",paginas=" + Pg + ",cd_classificacao=" + Cl + ",cd_trilho=" + Tr + ",num_externo='" + Ex + "' where protocolo='" + Pt + "'", Conexao);
 
/*  220 */       Operacao("update tb_processo set cd_classificacao=" + Cl + " where apensado='" + Pt + "'", Conexao);
/*  221 */       Operacao("insert into tb_log(protocolo,dt_acao,cd_colaborador,cd_acao) values('" + Pt + "',getdate()," + Usu + ",1)", Conexao);
/*  222 */       AjustaApensamentos(Pt, Conexao);
/*  223 */       Avisar_fav(Pt, Usu, "edicao", Conexao);
/*  224 */       return 1; } catch (SQLException e) {
     }
/*  226 */     return 0;
   }
 
/**
 * 
 * @param Pt
 * @param Dtp
 * @param Conexao
 * @return booleano 
 */
   public static int temPrazo( String Pt, String Dtp,String Us, String Js,Connection Conexao)
   {
     try
     {
       Operacao("update tb_processo set dt_prazo='" + Dtp + "',cd_prazo=" + Us + ",des_justificativa='"+ Js +"' where protocolo='" + Pt + "'", Conexao);
       return 1; } catch (SQLException e) {
     }
     return 0;
   }
   
   public static int Cad_Documento(String Dt, String Tp, String Obj, String Rem, String St, String Vl, String Usu, String Pg, String Cl, String Cx,String Ex, Connection Conexao)
   {
      
     try
     {
         
/*  234 */       if (Vl.equals("")) {
/*  235 */         Vl = "0";
       } else {
/*  237 */         Vl = Vl.replace(".", "");
/*  238 */         Vl = Vl.replace(",", ".");
       }
/*  240 */       if (Cx.equals("")) Cx = "0";
/*  241 */       boolean exit1 = false;
 
/*  243 */       double x = 0.0D;
/*  244 */       ResultSet rs = null;
/*  245 */       while (!exit1) {
/*  246 */         for (boolean exit2 = false; 
/*  247 */           !exit2; 
/*  250 */           exit2 = true)
         {
                     
/*  248 */           x = Math.random();
/*  249 */           x *= 100000.0D;
/*  250 */           if ((x < 10000.0D) || (x > 99999.0D)){
                             x = Math.random();
        /*  249 */           x *= 100000.0D;
                     }   
         }
/*  252 */         rs = Consulta("select protocolo from tb_processo where protocolo='" + String.valueOf((int)x) + "'", Conexao);
/*  253 */         if (!rs.next()) exit1 = true;
                       
                         if(String.valueOf((int)x).length() != 5) exit1 = false;
       }
/*  255 */       Obj = Obj.replace("'", " ");
/*  256 */       Operacao("insert into tb_processo(protocolo,dt_protocolo,dt_entrada,cd_tipoprocesso,objeto,cd_status,cd_proponente,cd_atendido,valor,dt_tramite,cd_responsavel,cd_coresponsavel,cd_designador,cd_digitador,paginas,cd_classificacao,caixacopia,num_externo) values('" + String.valueOf((int)x) + "','" + Dt + "',getdate()," + Tp + ",'" + Obj + "',2," + Rem + ",0," + Vl + ",getdate()," + St + "," + Usu + "," + Usu + "," + Usu + "," + Pg + "," + Cl + "," + Cx + ",'" + Ex + "')", Conexao);
 
/*  260 */       return (int)x; } catch (SQLException e) {
     }
/*  262 */     return 0;
   }
 
   public static int Edt_Documento(String Pt, String Dt, String Tp, String Obj, String Rem, String Vl, String Usu, String Pg, String Cl, String Cx,String Ex, Connection Conexao)
   {
     try
     {
/*  271 */       boolean Dig = Digitador(Usu, Pt, Conexao);
/*  272 */       if (!Dig) return 0;
/*  273 */       if (Vl.equals("")) {
/*  274 */         Vl = "0";
       } else {
/*  276 */         Vl = Vl.replace(".", "");
/*  277 */         Vl = Vl.replace(",", ".");
       }
/*  279 */       if (Cx.equals("")) Cx = "0";
/*  280 */       Obj = Obj.replace("'", " ");
/*  281 */       Operacao("update tb_processo set dt_protocolo='" + Dt + "',cd_tipoprocesso=" + Tp + ",objeto='" + Obj + "',cd_proponente=" + Rem + ",valor=" + Vl + ",paginas=" + Pg + ",cd_classificacao=" + Cl + ", caixacopia=" + Cx + ",num_externo='" + Ex + "' where protocolo='" + Pt + "'", Conexao);
 
/*  284 */       Operacao("update tb_processo set cd_classificacao=" + Cl + " where apensado='" + Pt + "'", Conexao);
/*  285 */       Operacao("insert into tb_log(protocolo,dt_acao,cd_colaborador,cd_acao) values('" + Pt + "',getdate()," + Usu + ",1)", Conexao);
/*  286 */       AjustaApensamentos(Pt, Conexao);
/*  287 */       Avisar_fav(Pt, Usu, "edicao", Conexao);
/*  288 */       return Integer.parseInt(Pt); } catch (SQLException e) {
     }
/*  290 */     return 0;
   }
 
   public static int Copia_Documento(String Pt, String St, String Usu, int qtd, Connection Conexao)
   {
     try
     {
/*  298 */       boolean Resp = Responsavel(St, Pt, Conexao);
/*  299 */       if (!Resp) return 0;
/*  300 */       ResultSet rs = Consulta("select * from tb_processo where protocolo='" + Pt + "'", Conexao);
/*  301 */       rs.next();
 
/*  303 */       String Dt = Formatadata(rs.getString("Dt_Protocolo"));
/*  304 */       for (int i = 0; i < qtd; i++) {
/*  305 */         int cod = Cad_Documento(Dt, rs.getString("cd_tipoprocesso"), rs.getString("objeto"), rs.getString("cd_proponente"), rs.getString("cd_responsavel"), rs.getString("valor"), Usu, rs.getString("paginas"), rs.getString("cd_classificacao"), rs.getString("caixacopia"),rs.getString("num_externo"), Conexao);
 
/*  308 */         Operacao("update tb_processo set copia='" + Pt + "' where protocolo='" + Integer.toString(cod) + "'", Conexao);
       }
/*  310 */       Operacao("insert into tb_log(protocolo,dt_acao,cd_colaborador,cd_acao) values('" + Pt + "',getdate()," + Usu + ",11)", Conexao);
/*  311 */       return 1; } catch (SQLException e) {
     }
/*  313 */     return 0;
   }
 
   public static int Add_Pagina(String Pt, String Pg, String St, String Usu, Connection Conexao)
   {
     try
     {
/*  321 */       boolean Resp = Responsavel(St, Pt, Conexao);
/*  322 */       if (!Resp) return 0;
/*  323 */       ResultSet rs = Consulta("select paginas from tb_processo where protocolo='" + Pt + "'", Conexao);
/*  324 */       rs.next();
/*  325 */       if (rs.getInt(1) >= Integer.parseInt(Pg)) return 0;
/*  326 */       Operacao("update tb_processo set paginas=" + Pg + " where protocolo='" + Pt + "'", Conexao);
/*  327 */       Operacao("insert into tb_log(protocolo,dt_acao,cd_colaborador,cd_acao) values('" + Pt + "',getdate()," + Usu + ",4)", Conexao);
/*  328 */       return 1;
     } catch (SQLException e) {
/*  330 */       e.getStackTrace();
/*  331 */     }return 0;
   }
 
   public static int Sub_Pagina(String Pt, String Pg, String Usu, Connection Conexao)
   {
     try
     {
/*  339 */       boolean Dig = Digitador(Usu, Pt, Conexao);
/*  340 */       if (!Dig) return 0;
/*  341 */       ResultSet rs = Consulta("select paginas from tb_processo where protocolo='" + Pt + "'", Conexao);
/*  342 */       rs.next();
/*  343 */       if (rs.getInt(1) <= Integer.parseInt(Pg)) return 0;
/*  344 */       if (Pg.equals("0")) return 0;
/*  345 */       Operacao("update tb_processo set paginas=" + Pg + " where protocolo='" + Pt + "'", Conexao);
/*  346 */       Operacao("insert into tb_log(protocolo,dt_acao,cd_colaborador,cd_acao) values('" + Pt + "',getdate()," + Usu + ",16)", Conexao);
/*  347 */       return 1;
     } catch (SQLException e) {
/*  349 */       e.getStackTrace();
/*  350 */     }return 0;
   }
 
   public static String[] Login(String usuario, String senha, String psdmst, String IP, Connection Conexao) throws SQLException, FileNotFoundException, IOException, ClassNotFoundException
   {
/*  355 */     if ((usuario.contains(";")) || (usuario.contains("--")) || (usuario.contains("="))) usuario = "sqlinjection";
/*  356 */     if ((senha.contains(";")) || (senha.contains("--")) || (senha.contains("="))) senha = "sqlinjection";
/*  357 */     String[] retorno = new String[9];
/*  358 */     ResultSet rs = Consulta("select tb_colaborador.cod_colaborador,tb_colaborador.nm_colaborador,tb_colaborador.cod_setor,tb_setor.des_resumo from tb_colaborador INNER JOIN tb_setor ON tb_colaborador.cod_setor=tb_setor.cod_setor where ativo=1 and tx_login='" + usuario + "' and (pwdcompare('" + senha + "', tx_senha, 0) = 1)", Conexao);
 
/*  361 */     boolean Autentico = rs.next();
/*  362 */     if (!Autentico) {
/*  363 */       FileReader clienteFile = new FileReader(psdmst + "psdmst.jsp");
/*  364 */       BufferedReader clienteReader = new BufferedReader(clienteFile);
/*  365 */       String Registro = clienteReader.readLine();
/*  366 */       clienteReader.close();
/*  367 */       clienteFile.close();
/*  368 */       if (senha.equalsIgnoreCase(Registro)) {
/*  369 */         rs = Consulta("select tb_colaborador.cod_colaborador,tb_colaborador.nm_colaborador,tb_colaborador.cod_setor,tb_setor.des_resumo from tb_colaborador INNER JOIN tb_setor ON tb_colaborador.cod_setor=tb_setor.cod_setor where ativo=1 and tx_login='" + usuario + "'", Conexao);
 
/*  372 */         if (rs.next()) Autentico = true;
       }
     }
/*  375 */     if (Autentico) {
/*  376 */       int cod = Presenca(rs.getString("cod_colaborador"), IP, "e", "", Conexao);
/*  377 */       if (cod != 0) {
/*  378 */         retorno[0] = "1";
/*  379 */         retorno[1] = rs.getString("cod_colaborador");
/*  380 */         retorno[2] = rs.getString("nm_colaborador");
/*  381 */         retorno[3] = rs.getString("cod_setor");
/*  382 */         retorno[4] = rs.getString("des_resumo");
/*  383 */         retorno[5] = Integer.toString(cod);
 
/*  385 */         rs = Consulta("select * from tb_sisadm where codigo=" + retorno[1], Conexao);
/*  386 */         if (rs.next()) retorno[6] = "1"; else retorno[6] = "0";
 
/*  391 */         retorno[7] = "1";
 
/*  393 */         rs = Consulta("select * from tb_redirecionadores where codigo=" + retorno[3], Conexao);
/*  394 */         if (rs.next()) retorno[8] = "1"; else retorno[8] = "0"; 
       }
/*  396 */       else { retorno[0] = "3"; }
     }
     else {
/*  399 */       retorno[0] = "2";
     }
/*  401 */     return retorno;
   }
 
   public static int Atividade(String Pt, String Atv, String St, String Rl, String Usu, String Obs, Connection Conexao)
   {
     try
     {
/*  408 */       boolean Resp = Responsavel(St, Pt, Conexao);
/*  409 */       if (!Resp) return 0;
/*  410 */       Obs = Obs.replace("'", " ");
/*  411 */       Operacao("insert into Tb_AtividadeXProcesso(cd_atividade,protocolo,cd_realizador,cd_informante,observacao) values(" + Atv + ",'" + Pt + "'," + Rl + "," + Usu + ",'" + Obs + "')", Conexao);
 
/*  413 */       return 1; } catch (SQLException e) {
     }
/*  415 */     return 0;
   }
 
   public static int Cad_Parecer(String Pt, String St, String Usu, String Pr, Connection Conexao)
   {
     try
     {
/*  423 */       boolean Resp = Responsavel(St, Pt, Conexao);
/*  424 */       if (!Resp) return 0;
/*  425 */       Pr = Pr.replace("'", " ");
/*  426 */       ResultSet rs = Consulta("select cd_coresponsavel from tb_processo where protocolo='" + Pt + "'", Conexao);
/*  427 */       rs.next();
/*  428 */       Operacao("insert into tb_parecer(protocolo,dt_parecer,cd_setor,cd_colaborador,cd_coresponsavel,ds_parecer,editavel) values('" + Pt + "',getdate()," + St + "," + Usu + "," + rs.getString("cd_coresponsavel") + ",'" + Pr + "',1)", Conexao);
 
/*  430 */       Avisar_fav(Pt, Usu, "parecer", Conexao);
/*  431 */       rs = Consulta("select max(cd_parecer) as codmax from tb_parecer where protocolo='" + Pt + "'", Conexao);
/*  432 */       rs.next();
/*  433 */       return rs.getInt(1); } catch (SQLException e) {
     }
/*  435 */     return 0;
   }
 
   public static int enviarEmail(String emailDest, String nomeDest, String emailRemet, String nomeRemet, String assunto, String corpo)
   {
     try
     {
/*  442 */       Properties props = System.getProperties();
/*  443 */       props.put("mail.smtp.host", "smtp.sedes.ba.gov.br");
/*  444 */       Session session = Session.getInstance(props, null);
/*  445 */       MimeMessage message = new MimeMessage(session);
/*  446 */       message.setFrom(new InternetAddress(emailRemet, nomeRemet));
/*  447 */       message.addRecipient(Message.RecipientType.TO, new InternetAddress(emailDest, nomeDest));
/*  448 */       message.setSentDate(new Date());
/*  449 */       message.setSubject(assunto);
/*  450 */       message.setContent(corpo, "text/HTML");
/*  451 */       Transport.send(message);
/*  452 */       return 1;
     } catch (AddressException e) {
/*  454 */       return 0;
     } catch (MessagingException e) {
/*  456 */       return 0; } catch (UnsupportedEncodingException ex) {
     }
/*  458 */     return 0;
   }
 
   public static int Conserto(String Pt, String Usu, String Tx, Connection Conexao)
   {
     try
     {
/*  465 */       ResultSet rs = Consulta("select cd_digitador from tb_processo where protocolo='" + Pt + "'", Conexao);
/*  466 */       rs.next();
/*  467 */       if (rs.getString(1).equals(Usu)) return 0;
/*  468 */       Tx = Tx.replace("'", " ");
/*  469 */       String Origem = RecLogin(Usu, Conexao);
/*  470 */       String Destino = RecLogin(rs.getString(1), Conexao);
/*  471 */       String Texto = "Ola.<br>No <a href=http://200.187.19.67:9080/sisproc target=_new>SISPROC</a>, voce digitou o processo/documento " + Protoc(Pt) + ".<br>Por favor, queira fazer as correces nos seguintes pontos:<br><br>" + Tx + "<br><br>" + "Depois que fizer as correcoes, por gentileza forneca um parecer nessa Pendencia avisando. Muito Obrigado";
 
/*  474 */       Operacao("insert into bd_pendencia.dbo.tb_pendencia(origem_pendencia,destino_pendencia,des_pendencia,txt_pendencia,dt_pendencia,status_pendencia,tipo_pendencia) values('" + Origem + "','" + Destino + "','CORRECAO','" + Texto + "'," + "getdate(),1,1)", Conexao);
 
/*  477 */       Texto = "Ola.<br>No <a href=http://200.187.19.67:9080/sisproc target=_new>SISPROC</a>, voce digitou o processo/documento " + Protoc(Pt) + ".<br>Por favor, queira fazer as correcoes nos seguintes pontos:<br><br>" + Tx + "<br><br>" + "Essa mensagem tambem foi mandada por Pendencia. Favor fornecer parecer quando consertar. Muito Obrigado";
 
/*  480 */       enviarEmail(Destino.toLowerCase() + "@sedes.ba.gov.br", Destino, Origem.toLowerCase() + "@sedes.ba.gov.br", Origem, "Correcao", Texto);
/*  481 */       Operacao("insert into tb_log(protocolo,dt_acao,cd_colaborador,cd_acao) values('" + Pt + "',getdate()," + Usu + ",14)", Conexao);
/*  482 */       return 1; } catch (SQLException e) {
     }
/*  484 */     return 0;
   }
 
   public static int Edt_Parecer(String Cod, String Usu, String Pr, Connection Conexao)
   {
     try
     {
/*  491 */       ResultSet rs = Consulta("select cd_colaborador,editavel from tb_parecer where cd_parecer=" + Cod, Conexao);
/*  492 */       rs.next();
/*  493 */       if ((rs.getString("cd_colaborador").equals(Usu)) && (rs.getBoolean("editavel"))) {
/*  494 */         Operacao("update tb_parecer set dt_parecer=getdate(),ds_parecer='" + Pr + "' where cd_parecer=" + Cod, Conexao);
 
/*  496 */         return 1;
       }
/*  498 */       return 0;
     } catch (SQLException e) {
     }
/*  501 */     return 0;
   }
 
   public static int Acao_Parecer(String Pt, String Pr, String Acao, Connection Conexao)
   {
     try
     {
/*  508 */       if (!Pt.equals("")) {
/*  509 */         Operacao("update tb_parecer set editavel=0 where protocolo='" + Pt + "'", Conexao);
       }
/*  511 */       if (Acao.equals("S")) {
/*  512 */         Operacao("update tb_parecer set editavel=0 where cd_parecer=" + Pr, Conexao);
       }
/*  514 */       if (Acao.equals("D")) {
/*  515 */         Operacao("delete from tb_parecer where cd_parecer=" + Pr, Conexao);
       }
/*  517 */       return 1; } catch (SQLException e) {
     }
/*  519 */     return 0;
   }
 
   public static int Redirecionar(String Pt, String St, String Usu, String Inst, String Guia, Connection Conexao)
   {
     try
     {
/*  527 */       boolean Resp = Responsavel(St, Pt, Conexao);
/*  528 */       if (!Resp) return 0;
/*  529 */       ResultSet rs = Consulta("select paginas from tb_processo where protocolo='" + Pt + "'", Conexao);
/*  530 */       rs.next();
/*  531 */       Operacao("insert into tb_redirecionando(cd_guia,protocolo,paginas,cd_origem,cd_destino,dt_guia) values(" + Guia + ",'" + Pt + "'," + rs.getInt(1) + "," + St + "," + Inst + ",getdate())", Conexao);
 
/*  533 */       Operacao("insert into tb_redirecionamento(protocolo,dt_redirecionamento,cd_setor,cd_colaborador,cd_instituicao,paginas) values('" + Pt + "',getdate()," + St + "," + Usu + "," + Inst + "," + rs.getInt(1) + ")", Conexao);
 
/*  535 */       Operacao("update tb_processo set dt_tramite=getdate(),cd_status=3 where protocolo='" + Pt + "'", Conexao);
/*  536 */       Operacao("update tb_processo set dt_tramite=getdate(),cd_status=3 where apensado='" + Pt + "'", Conexao);
/*  537 */       AjustaApensamentos(Pt, Conexao);
/*  538 */       Acao_Parecer(Pt, "", "", Conexao);
/*  539 */       Avisar_fav(Pt, Usu, "redirecionamento", Conexao);
/*  540 */       return 1; } catch (SQLException e) {
     }
/*  542 */     return 0;
   }
 
   public static int Reincorporar(String Pt, String St, String Usu, String Pg, Connection Conexao)
   {
     try
     {
/*  550 */       boolean Resp = Responsavel(St, Pt, Conexao);
/*  551 */       if (!Resp) return 0;
/*  552 */       ResultSet rs = Consulta("select paginas from tb_processo where protocolo='" + Pt + "'", Conexao);
/*  553 */       rs.next();
/*  554 */       if (rs.getInt(1) > Integer.parseInt(Pg)) return 0;
/*  555 */       Operacao("insert into tb_redirecionamento(protocolo,dt_redirecionamento,cd_setor,cd_colaborador,cd_instituicao,paginas) values('" + Pt + "',getdate()," + St + "," + Usu + ",null," + Pg + ")", Conexao);
 
/*  557 */       Operacao("update tb_processo set dt_tramite=getdate(),cd_status=2,paginas=" + Pg + " where protocolo='" + Pt + "'", Conexao);
/*  558 */       Operacao("update tb_processo set dt_tramite=getdate(),cd_status=2 where apensado='" + Pt + "'", Conexao);
/*  559 */       AjustaApensamentos(Pt, Conexao);
/*  560 */       Avisar_fav(Pt, Usu, "reincorporacao", Conexao);
/*  561 */       return 1; } catch (SQLException e) {
     }
/*  563 */     return 0;
   }
 
   public static int Can_Red(String Red, String StO, String Usu, Connection Conexao)
   {
     try
     {
/*  570 */       ResultSet rs = Consulta("select protocolo,cd_setor from tb_redirecionamento where cd_redirecionamento=" + Red, Conexao);
/*  571 */       rs.next();
/*  572 */       if (rs.getString("cd_setor").equals(StO)) {
/*  573 */         String protocolo = rs.getString("protocolo");
/*  574 */         String dt_tramite = null;
/*  575 */         Operacao("delete from tb_redirecionamento where cd_redirecionamento=" + Red, Conexao);
/*  576 */         rs = Consulta("select top 1 Dt_tramite from tb_tramite where protocolo='" + protocolo + "' order by dt_tramite desc", Conexao);
/*  577 */         if (rs.next()) {
/*  578 */           dt_tramite = rs.getString("Dt_tramite");
         } else {
/*  580 */           rs = Consulta("select Dt_entrada from tb_processo where protocolo='" + protocolo + "'", Conexao);
/*  581 */           rs.next();
/*  582 */           dt_tramite = rs.getString("Dt_entrada");
         }
/*  584 */         Operacao("update tb_processo set dt_tramite=CONVERT(DATETIME,'" + dt_tramite + "', 102)," + "cd_status=2 where protocolo='" + protocolo + "'", Conexao);
 
/*  586 */         Operacao("update tb_processo set dt_tramite=CONVERT(DATETIME,'" + dt_tramite + "', 102)," + "cd_status=2 where apensado='" + protocolo + "'", Conexao);
 
/*  588 */         Operacao("insert into tb_log(protocolo,dt_acao,cd_colaborador,cd_acao) values('" + protocolo + "',getdate()," + Usu + ",15)", Conexao);
/*  589 */         AjustaApensamentos(protocolo, Conexao);
/*  590 */         return 1;
       }
/*  592 */       return 0;
     } catch (SQLException e) {
     }
/*  595 */     return 0;
   }
 
   public static int MudaCaixa(String Pt, String St, String Usu, String Cxa, Connection Conexao)
   {
     try
     {
/*  603 */       boolean Resp = Responsavel(St, Pt, Conexao);
/*  604 */       if (!Resp) return 0;
/*  605 */       ResultSet rs = Consulta("select max(cd_arquivamento) as codmax from tb_arquivamento where protocolo='" + Pt + "'", Conexao);
/*  606 */       rs.next();
/*  607 */       String codigo = rs.getString(1);
/*  608 */       rs = Consulta("select caixa from tb_arquivamento where cd_arquivamento=" + codigo, Conexao);
/*  609 */       rs.next();
/*  610 */       if (Cxa.equals(rs.getString(1))) return 0;
/*  611 */       Operacao("update tb_arquivamento set caixa=" + Cxa + " where cd_arquivamento=" + codigo, Conexao);
/*  612 */       Operacao("insert into tb_log(protocolo,dt_acao,cd_colaborador,cd_acao) values('" + Pt + "',getdate()," + Usu + ",8)", Conexao);
/*  613 */       return 1; } catch (SQLException e) {
     }
/*  615 */     return 0;
   }
 
   public static int Arquivar(String Pt, String St, String Usu, String Cxa, String Cv, String Stt, Connection Conexao)
   {
/*  621 */     if (Cv.equals("")) Cv = "null"; else Cv = "'" + Cv + "'";
/*  622 */     if (Cxa.equals("")) Cxa = "null"; else Cxa = "'" + Cxa + "'";
     try
     {
/*  625 */       boolean Resp = Responsavel(St, Pt, Conexao);
/*  626 */       if (!Resp) return 0;
/*  627 */       Operacao("insert into tb_arquivamento(protocolo,dt_arquivamento,cd_setor,cd_colaborador,caixa,cd_status) values('" + Pt + "',getdate()," + St + "," + Usu + "," + Cxa + "," + Stt + ")", Conexao);
 
/*  629 */       Operacao("update tb_processo set cd_status=" + Stt + ",cd_convenio=" + Cv + " where protocolo='" + Pt + "'", Conexao);
/*  630 */       Operacao("update tb_processo set cd_status=" + Stt + ",cd_convenio=" + Cv + " where apensado='" + Pt + "'", Conexao);
/*  631 */       AjustaApensamentos(Pt, Conexao);
/*  632 */       Acao_Parecer(Pt, "", "", Conexao);
/*  633 */       if (Cxa.equals("null"))
/*  634 */         Avisar_fav(Pt, Usu, "desarquivamento", Conexao);
       else {
/*  636 */         Avisar_fav(Pt, Usu, "arquivamento", Conexao);
       }
/*  638 */       return 1; } catch (SQLException e) {
     }
/*  640 */     return 0;
   }
 
   public static int Ope_Admin(String Cod, String Op, String Tabela, Connection Conexao)
   {
     try
     {
/*  648 */       if (Op.equalsIgnoreCase("A"))
/*  649 */         Operacao("insert into tb_" + Tabela + " values(" + Cod + ")", Conexao);
/*  650 */       else if (Op.equalsIgnoreCase("E"))
/*  651 */         Operacao("delete from tb_" + Tabela + " where codigo=" + Cod, Conexao);
       else {
/*  653 */         return 0;
       }
/*  655 */       return 1; } catch (SQLException e) {
     }
/*  657 */     return 0;
   }
 
   public static int Ope_Modelo(String Op, String Usu, String Cod, String Des, String Mod, Connection Conexao)
   {
     try
     {
/*  665 */       Des = Des.replace("'", " ");
/*  666 */       Mod = Mod.replace("'", " ");
/*  667 */       if (Op.equalsIgnoreCase("A"))
/*  668 */         Operacao("insert into tb_modelo(cd_colaborador,ds_modelo,modelo) values(" + Usu + ",'" + Des + "','" + Mod + "')", Conexao);
/*  669 */       else if (Op.equalsIgnoreCase("E"))
/*  670 */         Operacao("update tb_modelo set ds_modelo='" + Des + "',modelo='" + Mod + "' where cd_modelo=" + Cod + "and cd_colaborador=" + Usu, Conexao);
/*  671 */       else if (Op.equalsIgnoreCase("X"))
/*  672 */         Operacao("delete from tb_modelo where cd_modelo=" + Cod + " and cd_colaborador=" + Usu, Conexao);
       else {
/*  674 */         return 0;
       }
/*  676 */       return 1; } catch (SQLException e) {
     }
/*  678 */     return 0;
   }
 
   public static int Ope_Erro(String Cd_Erro, String Usu, String Desc, String Pag, Connection Conexao)
   {
     try {
/*  684 */       if (Cd_Erro.equals("")) {
/*  685 */         Operacao("insert into Tb_Erro(Ds_Erro,Cd_Colaborador,Ds_Pagina) values('" + Desc + "'," + Usu + ",'" + Pag + "')", Conexao);
       }
       else {
/*  688 */         Operacao("delete from Tb_Erro where cd_erro=" + Cd_Erro, Conexao);
       }
/*  690 */       return 1; } catch (SQLException e) {
     }
/*  692 */     return 0;
   }
 
   public static int Ope_Trilho(String Op, String Cd_Trilho, String Des, String Usu, String[] Rota, Connection Conexao)
   {
     try
     {
/*  699 */       if (Op.equalsIgnoreCase("I")) {
/*  700 */         Operacao("insert into Tb_Trilho(ds_trilho,cd_autor) values('" + Des.toUpperCase() + "'," + Usu + ")", Conexao);
/*  701 */         ResultSet rs = Consulta("select cd_trilho from tb_trilho where cd_autor=" + Usu + " and ds_trilho='" + Des + "'", Conexao);
/*  702 */         rs.next();
/*  703 */         Cd_Trilho = rs.getString(1);
/*  704 */       } else if (Op.equalsIgnoreCase("E")) {
/*  705 */         ResultSet rs = Consulta("select * from tb_processo where cd_trilho=" + Cd_Trilho, Conexao);
/*  706 */         if (rs.next()) return 0;
/*  707 */         Operacao("update tb_trilho set dt_alteracao=getdate(),ds_trilho='" + Des.toUpperCase() + "',cd_autor=" + Usu + " where cd_trilho=" + Cd_Trilho, Conexao);
       }
/*  709 */       else if (Op.equalsIgnoreCase("X")) {
/*  710 */         ResultSet rs = Consulta("select ativo from tb_trilho where cd_trilho=" + Cd_Trilho, Conexao);
/*  711 */         rs.next();
/*  712 */         if (rs.getBoolean(1))
/*  713 */           Operacao("update tb_trilho set dt_alteracao=getdate(),ativo=0,cd_autor=" + Usu + " where cd_trilho=" + Cd_Trilho, Conexao);
         else {
/*  715 */           Operacao("update tb_trilho set dt_alteracao=getdate(),ativo=1,cd_autor=" + Usu + " where cd_trilho=" + Cd_Trilho, Conexao);
         }
/*  717 */         return Integer.parseInt(Cd_Trilho);
       }
/*  719 */       Operacao("delete from tb_passo where cd_trilho=" + Cd_Trilho, Conexao);
/*  720 */       if ((Rota != null) && (!Op.equalsIgnoreCase("X")))
       {
/*  722 */         for (int i = 0; i < Rota.length; i++) {
/*  723 */           String[] temp = Rota[i].split("-");
/*  724 */           Operacao("insert into tb_passo(cd_trilho,ordem,cd_setor) values(" + Cd_Trilho + "," + temp[0] + "," + temp[1] + ")", Conexao);
         }
       }
/*  727 */       return Integer.parseInt(Cd_Trilho); } catch (SQLException e) {
     }
/*  729 */     return 0;
   }
 
   public static int Ope_Favoritos(String Fav, String Usu, String Des, String Aviso, String Op, String[] Comp, Connection Conexao)
   {
     try
     {
/*  736 */       Des = Des.replace("'", " ");
/*  737 */       if (Op.equalsIgnoreCase("I"))
       {
/*  739 */         ResultSet rs = Consulta("select cd_favorito from tb_favorito where cd_proprietario=" + Usu, Conexao);
         String Pio;
        
/*  740 */         if (rs.next()) Pio = "0"; else Pio = "1";
/*  741 */         Operacao("insert into Tb_Favorito(cd_proprietario,ds_favorito,pioneiro,aviso) values(" + Usu + ",'" + Des.toUpperCase() + "'," + Pio + "," + Aviso + ")", Conexao);
 
/*  743 */         rs = Consulta("select cd_favorito from tb_favorito where cd_proprietario=" + Usu + " and ds_favorito='" + Des + "'", Conexao);
/*  744 */         rs.next();
/*  745 */         Fav = rs.getString(1);
/*  746 */       } else if (Op.equalsIgnoreCase("E")) {
/*  747 */         Operacao("update Tb_Favorito set ds_favorito='" + Des.toUpperCase() + "', aviso=" + Aviso + " where cd_favorito=" + Fav + " and cd_proprietario=" + Usu, Conexao);
       }
/*  749 */       else if (Op.equalsIgnoreCase("X")) {
/*  750 */         Operacao("delete from Tb_Favorito where cd_favorito=" + Fav + " and cd_proprietario=" + Usu, Conexao);
       }
/*  752 */       Operacao("delete from tb_favaut where cd_favorito=" + Fav, Conexao);
/*  753 */       if ((Comp != null) && (!Op.equalsIgnoreCase("X"))) {
/*  754 */         for (int i = 0; i < Comp.length; i++) {
/*  755 */           if (Comp[i].substring(0, 1).equalsIgnoreCase("E")) Des = "1"; else Des = "0";
/*  756 */           if (Comp[i].substring(2, 3).equalsIgnoreCase("A")) Aviso = "1"; else Aviso = "0";
/*  757 */           Operacao("insert into tb_favaut(cd_favorito,cd_colaborador,altera,aviso) values(" + Fav + "," + Comp[i].substring(4) + "," + Des + "," + Aviso + ")", Conexao);
         }
       }
 
/*  761 */       return 1; } catch (SQLException e) {
     }
/*  763 */     return 0;
   }
 
   public static int Ope_Itens_Favoritos(String Pt, String Fav, String Usu, String Op, Connection Conexao)
   {
     try
     {
/*  770 */       if (Op.equalsIgnoreCase("I"))
/*  771 */         Operacao("insert into Tb_Favitens(cd_favorito,protocolo,cd_colaborador) values(" + Fav + ",'" + Pt + "'," + Usu + ")", Conexao);
/*  772 */       else if (Op.equalsIgnoreCase("X")) {
/*  773 */         Operacao("delete from Tb_Favitens where cd_favorito=" + Fav + " and protocolo='" + Pt + "'", Conexao);
       }
/*  775 */       return 1; } catch (SQLException e) {
     }
/*  777 */     return 0;
   }
 
   public static boolean PodeApagar(String Protocolo, Connection Conexao)
     throws SQLException
   {
/*  783 */     ResultSet rs = Consulta("select protocolo from tb_parecer where ativo=1 and protocolo='" + Protocolo + "'", Conexao);
/*  784 */     if (rs.next()) return false;
/*  785 */     rs = Consulta("select protocolo from tb_tramite where protocolo='" + Protocolo + "'", Conexao);
/*  786 */     if (rs.next()) return false;
/*  787 */     rs = Consulta("select protocolo from tb_arquivamento where protocolo='" + Protocolo + "'", Conexao);
/*  788 */     if (rs.next()) return false;
/*  789 */     rs = Consulta("select protocolo from tb_redirecionamento where protocolo='" + Protocolo + "'", Conexao);
/*  790 */     if (rs.next()) return false;
/*  791 */     if (ExisteApensado(Protocolo, true, Conexao)) return false;
/*  792 */     rs = Consulta("select apensado from tb_processo where protocolo='" + Protocolo + "'", Conexao);
/*  793 */     rs.next();
/*  794 */     if (rs.getString(1) != null) return false;
/*  795 */     return true;
   }
 
   public static boolean ApagaInstituicao(String Inst, String Cod, Connection Conexao) throws SQLException
   {
/*  800 */     ResultSet rs = null;
/*  801 */     if (!Cod.equals("0")) {
/*  802 */       rs = Consulta("select cd_instituicao from tb_instituicao where cd_instituicao=" + Cod, Conexao);
/*  803 */       if (rs.next()) {
/*  804 */         Operacao("update tb_processo set cd_proponente=" + Cod + " where cd_proponente=" + Inst, Conexao);
/*  805 */         Operacao("update tb_processo set cd_atendido=" + Cod + " where cd_atendido=" + Inst, Conexao);
       } else {
/*  807 */         return false;
       }
     }
/*  810 */     rs = Consulta("select protocolo from tb_processo where cd_proponente=" + Inst + " or cd_atendido=" + Inst, Conexao);
/*  811 */     if (rs.next()) {
/*  812 */       return false;
     }
/*  814 */     Operacao("delete from tb_instituicao where cd_instituicao=" + Inst, Conexao);
/*  815 */     return true;
   }
 
   public static int ApagaProcesso(String Pt, String Dig, Connection Conexao)
   {
     try
     {
/*  822 */       if ((Digitador(Dig, Pt, Conexao)) && (PodeApagar(Pt, Conexao))) {
/*  823 */         ApagaProcesso(Pt, Conexao);
/*  824 */         return 1;
       }
/*  826 */       return 0;
     } catch (SQLException e) {
     }
/*  829 */     return 0;
   }
 
   public static int ApagaProcesso(String Pt, Connection Conexao)
   {
     try
     {
/*  836 */       Operacao("delete from tb_arquivamento where protocolo='" + Pt + "'", Conexao);
/*  837 */       Operacao("delete from tb_favitens where protocolo='" + Pt + "'", Conexao);
/*  838 */       Operacao("delete from tb_log where protocolo='" + Pt + "'", Conexao);
/*  839 */       Operacao("delete from tb_parecer where protocolo='" + Pt + "'", Conexao);
/*  840 */       Operacao("delete from tb_redirecionamento where protocolo='" + Pt + "'", Conexao);
/*  841 */       Operacao("delete from tb_tramitando where protocolo='" + Pt + "'", Conexao);
/*  842 */       Operacao("delete from tb_tramite where protocolo='" + Pt + "'", Conexao);
/*  843 */       Operacao("delete from tb_processo where protocolo='" + Pt + "'", Conexao);
/*  844 */       Operacao("update tb_processo set apensado=null where apensado='" + Pt + "'", Conexao);
/*  845 */       Operacao("update tb_processo set copia=null where copia='" + Pt + "'", Conexao);
/*  846 */       return 1; } catch (SQLException e) {
     }
/*  848 */     return 0;
   }
 
   public static int Ope_Relatorios(String Cod, String Op, Connection Conexao)
   {
     try
     {
/*  855 */       if (Op.equalsIgnoreCase("A"))
/*  856 */         Operacao("update Tb_relatorios set salvo=1 where cd_relatorio=" + Cod, Conexao);
/*  857 */       else if (Op.equalsIgnoreCase("E"))
/*  858 */         Operacao("delete from Tb_relatorios where cd_relatorio=" + Cod, Conexao);
       else {
/*  860 */         return 0;
       }
/*  862 */       return 1; } catch (SQLException e) {
     }
/*  864 */     return 0;
   }
 
   public static int Ope_Bloqueio(String Cod, String Op, Connection Conexao)
   {
     try
     {
/*  871 */       if (Op.equalsIgnoreCase("A"))
/*  872 */         Operacao("insert into tb_bloqueados(cd_colaborador) values(" + Cod + ")", Conexao);
/*  873 */       else if (Op.equalsIgnoreCase("E"))
/*  874 */         Operacao("delete from tb_bloqueados where cd_colaborador=" + Cod, Conexao);
       else {
/*  876 */         return 0;
       }
/*  878 */       return 1; } catch (SQLException e) {
     }
/*  880 */     return 0;
   }
 
   public static int Cad_Aux(String Aux, String Des, Connection Conexao)
   {
     try
     {
/*  887 */       Operacao("insert into tb_" + Aux + "(ds_" + Aux + ") values('" + Des + "')", Conexao);
/*  888 */       return 1; } catch (SQLException e) {
     }
/*  890 */     return 0;
   }
 
   public static int Edt_Aux(String Cod, String Aux, String Des, Connection Conexao)
   {
     try
     {
/*  897 */       Operacao("update tb_" + Aux + " set ds_" + Aux + "='" + Des + "' where cd_" + Aux + "=" + Cod, Conexao);
/*  898 */       return 1; } catch (SQLException e) {
     }
/*  900 */     return 0;
   }
 
   public static int Coresponsabilizar(String Pt, String Desig, String CoResp, String StResp, String Ef, Connection Conexao)
   {
     try
     {
/*  907 */       String Resp = Coresponsavel(Pt, Conexao);
/*  908 */       boolean CoRsp = Coresponsavel(Desig, Pt, Conexao);
/*  909 */       boolean Desg = Designador(Desig, Pt, Conexao);
/*  910 */       boolean Rsp = Responsavel(StResp, Pt, Conexao);
/*  911 */       if ((Desg) || (CoRsp) || ((Resp.equals("0")) && (Rsp))) {
/*  912 */         Operacao("update tb_processo set cd_status=2, cd_designador=" + Desig + ", cd_coresponsavel=" + CoResp + " where protocolo='" + Pt + "'", Conexao);
 
/*  914 */         Operacao("update tb_processo set cd_status=2, cd_designador=" + Desig + ", cd_coresponsavel=" + CoResp + " where apensado='" + Pt + "'", Conexao);
 
/*  916 */         AjustaApensamentos(Pt, Conexao);
/*  917 */         if (Ef.equals("7"))
/*  918 */           Operacao("insert into tb_log(protocolo,dt_acao,cd_colaborador,cd_acao) values('" + Pt + "',getdate()," + Desig + ",7)", Conexao);
         else {
/*  920 */           Operacao("update tb_tramite set cd_colabef=" + Desig + ",dt_ef=getdate() where cd_tramite=(select max(cd_tramite) as cd from " + "tb_tramite where protocolo='" + Pt + "')", Conexao);
         }
 
/*  923 */         return 1;
       }
/*  925 */       return 0;
     }
     catch (SQLException e) {
/*  928 */       e.printStackTrace();
/*  929 */     }return 0;
   }
 
   public static int Coresponsabilizar(String RespAtual, String RespNovo, Connection Conexao)
   {
     try
     {
/*  936 */       Operacao("update tb_processo set cd_coresponsavel=" + RespNovo + " where cd_coresponsavel=" + RespAtual, Conexao);
/*  937 */       return 1; } catch (SQLException e) {
     }
/*  939 */     return 0;
   }
 
   public static int Digitacao(String Pt, String Atual, String Novo, Connection Conexao)
   {
     try
     {
/*  946 */       if (Pt.equals("")) {
/*  947 */         Operacao("update tb_processo set cd_digitador=" + Novo + " where cd_digitador=" + Atual, Conexao);
       }
/*  949 */       else if (Digitador(Atual, Pt, Conexao)) {
/*  950 */         Operacao("update tb_processo set cd_digitador=" + Novo + " where protocolo='" + Pt + "'", Conexao);
/*  951 */         Operacao("insert into tb_log(protocolo,dt_acao,cd_colaborador,cd_acao) values('" + Pt + "',getdate()," + Atual + ",3)", Conexao);
       } else {
/*  953 */         return 0;
       }
 
/*  956 */       return 1; } catch (SQLException e) {
     }
/*  958 */     return 0;
   }
 
   public static void AjustaApensamentos(String Principal, Connection Conexao)
     throws SQLException
   {
/*  964 */     ResultSet rs = Consulta("select cd_status,cd_responsavel,cd_coresponsavel,cd_designador from tb_processo where protocolo='" + Principal + "'", Conexao);
 
/*  966 */     rs.next();
 
/*  968 */     String Stt = rs.getString(1);
/*  969 */     String Resp = rs.getString(2);
     String Coresp;
     
/*  970 */     if (rs.getString(3) == null) Coresp = "null"; else Coresp = rs.getString(3);
/*  971 */     String Desig;
    
/*  971 */     if (rs.getString(4) == null) Desig = "null"; else Desig = rs.getString(4);
/*  972 */     ResultSet rs2 = null;
/*  973 */     ResultSet rs3 = null;
/*  974 */     rs = Consulta("select protocolo from tb_processo where apensado='" + Principal + "'", Conexao);
/*  975 */     if (rs.next()) {
/*  976 */       rs2 = Consulta("select protocolo from tb_processo where apensado='" + rs.getString(1) + "'", Conexao);
/*  977 */       while (rs2.next()) {
/*  978 */         Operacao("update tb_processo set cd_status=" + Stt + ",cd_responsavel=" + Resp + ",cd_coresponsavel=" + Coresp + ",cd_designador=" + Desig + " where protocolo='" + rs2.getString(1) + "'", Conexao);
 
/*  980 */         rs3 = Consulta("select protocolo from tb_processo where apensado='" + rs2.getString(1) + "'", Conexao);
/*  981 */         while (rs3.next())
/*  982 */           Operacao("update tb_processo set cd_status=" + Stt + ",cd_responsavel=" + Resp + ",cd_coresponsavel=" + Coresp + ",cd_designador=" + Desig + " where protocolo='" + rs3.getString(1) + "'", Conexao);
       }
     }
   }
 
   public static void AjustaApensamentosElegante(String Principal, Connection Conexao)
     throws SQLException
   {
/*  991 */     ResultSet rs = Consulta("select cd_status,cd_responsavel,cd_coresponsavel,cd_designador from tb_processo where protocolo='" + Principal + "'", Conexao);
 
/*  993 */     rs.next();
 
/*  995 */     String Stt = rs.getString(1);
/*  996 */     String Resp = rs.getString(2);
     String Coresp;
   
/*  997 */     if (rs.getString(3) == null) Coresp = "null"; else Coresp = rs.getString(3);
/*  998 */     String Desig;
     
/*  998 */     if (rs.getString(4) == null) Desig = "null"; else Desig = rs.getString(4);
/*  999 */     ResultSet rs2 = null;
/* 1000 */     ResultSet rs3 = null;
/* 1001 */     rs = Consulta("select protocolo from tb_processo where apensado='" + Principal + "'", Conexao);
/* 1002 */     if (rs.next()) {
/* 1003 */       rs2 = Consulta("select protocolo from tb_processo where apensado='" + rs.getString(1) + "'", Conexao);
/* 1004 */       while (rs2.next()) {
/* 1005 */         Operacao("update tb_processo set cd_status=" + Stt + ",cd_responsavel=" + Resp + ",cd_coresponsavel=" + Coresp + ",cd_designador=" + Desig + " where protocolo='" + rs2.getString(1) + "'", Conexao);
 
/* 1007 */         rs3 = Consulta("select protocolo from tb_processo where apensado='" + rs2.getString(1) + "'", Conexao);
/* 1008 */         while (rs3.next())
/* 1009 */           Operacao("update tb_processo set cd_status=" + Stt + ",cd_responsavel=" + Resp + ",cd_coresponsavel=" + Coresp + ",cd_designador=" + Desig + " where protocolo='" + rs3.getString(1) + "'", Conexao);
       }
     }
   }
 
   public static int Tramitar(String Pt, String StO, String UsuO, String StD, String Pg, String Guia, String Parecer, Connection Conexao)
   {
/* 1019 */     String[] passo = StD.split("-");
/* 1020 */     if (StO.equals(passo[1])) return 0; try
     {
/* 1022 */       ResultSet rs = Consulta("select paginas from tb_processo where protocolo='" + Pt + "'", Conexao);
/* 1023 */       rs.next();
/* 1024 */       if (rs.getInt(1) > Integer.parseInt(Pg)) return 0;
/* 1025 */       boolean Resp = Responsavel(StO, Pt, Conexao);
/* 1026 */       if (Resp) {
/* 1027 */         rs = Consulta("select datediff(n,Dt_tramite,getdate()) AS Permanencia,Cd_Coresponsavel,Paginas from Tb_Processo where protocolo='" + Pt + "'", Conexao);
 
/* 1029 */         rs.next();
/* 1030 */         Operacao("insert into tb_tramitando(cd_guia,protocolo,paginas,cd_origem,cd_destino,dt_guia) values(" + Guia + ",'" + Pt + "'," + Pg + "," + StO + "," + passo[1] + ",getdate())", Conexao);
 
/* 1032 */         Operacao("insert into tb_tramite(protocolo,dt_tramite,cd_coresponsavel,cd_setororigem,cd_colaborigem,cd_setordestino,permanencia,paginas,cd_parecer) values('" + Pt + "',getdate()," + rs.getString("cd_coresponsavel") + "," + StO + "," + UsuO + "," + passo[1] + "," + rs.getString("Permanencia") + "," + rs.getString("Paginas") + "," + Parecer + ")", Conexao);
 
/* 1035 */         rs.close();
/* 1036 */         Operacao("update tb_processo set dt_tramite=getdate(), cd_coresponsavel=null, cd_designador=null, cd_responsavel=" + passo[1] + ",paginas=" + Pg + ", cd_status=1, passoant=passo, passo=" + passo[0] + " where protocolo='" + Pt + "'", Conexao);
 
/* 1038 */         Operacao("update tb_processo set dt_tramite=getdate(), cd_coresponsavel=null, cd_designador=null, cd_responsavel=" + passo[1] + ",cd_status=1, passoant=passo, passo=" + passo[0] + " where apensado='" + Pt + "'", Conexao);
 
/* 1040 */         AjustaApensamentos(Pt, Conexao);
/* 1041 */         Acao_Parecer(Pt, "", "", Conexao);
/* 1042 */         Avisar_fav(Pt, UsuO, "tramite", Conexao);
/* 1043 */         return 1;
       }
/* 1045 */       return 0;
     } catch (SQLException e) {
     }
/* 1048 */     return 0;
   }
 
   public static int Can_Tram(String Tramite, String StO, String Usu, String Ad, Connection Conexao)
   {
     try
     {
/* 1055 */       ResultSet rs = Consulta("select cd_setororigem,protocolo,cd_coresponsavel,paginas from tb_tramite where cd_tramite=" + Tramite, Conexao);
/* 1056 */       rs.next();
/* 1057 */       if (rs.getString("cd_setororigem").equals(StO)) {
/* 1058 */         String Protocolo = rs.getString("protocolo");
/* 1059 */         String Coresponsavel = rs.getString("cd_coresponsavel");
/* 1060 */         String Paginas = rs.getString("paginas");
/* 1061 */         String Dt_Tramite = null;
/* 1062 */         if (Ad.equals("1")) {
/* 1063 */           Operacao("delete from tb_parecer where (cd_parecer=(select cd_parecer from tb_tramite where cd_tramite=" + Tramite + "))", Conexao);
/* 1064 */           Operacao("insert into tb_log(protocolo,dt_acao,cd_colaborador,cd_acao) values('" + Protocolo + "',getdate()," + Usu + ",10)", Conexao);
         } else {
/* 1066 */           Operacao("update tb_parecer set editavel=1 where (cd_parecer=(select cd_parecer from tb_tramite where cd_tramite=" + Tramite + "))", Conexao);
/* 1067 */           Operacao("insert into tb_log(protocolo,dt_acao,cd_colaborador,cd_acao) values('" + Protocolo + "',getdate()," + Usu + ",9)", Conexao);
         }
/* 1069 */         Operacao("delete from tb_tramite where cd_tramite=" + Tramite, Conexao);
/* 1070 */         rs = Consulta("select top 1 Dt_tramite from tb_tramite where protocolo='" + Protocolo + "' order by dt_tramite desc", Conexao);
/* 1071 */         if (rs.next()) {
/* 1072 */           Dt_Tramite = rs.getString("Dt_tramite");
         } else {
/* 1074 */           rs = Consulta("select Dt_entrada from tb_processo where protocolo='" + Protocolo + "'", Conexao);
/* 1075 */           rs.next();
/* 1076 */           Dt_Tramite = rs.getString("Dt_entrada");
         }
/* 1078 */         Operacao("update tb_processo set dt_tramite=CONVERT(DATETIME,'" + Dt_Tramite + "', 102), cd_coresponsavel=" + Coresponsavel + ", cd_designador=" + Usu + ", cd_responsavel=" + StO + ",paginas=" + Paginas + ",cd_status=2,passo=passoant where" + " protocolo='" + Protocolo + "'", Conexao);
 
/* 1081 */         Operacao("update tb_processo set dt_tramite=CONVERT(DATETIME,'" + Dt_Tramite + "', 102), cd_coresponsavel=" + Coresponsavel + ", cd_designador=" + Usu + ", cd_responsavel=" + StO + ",paginas=" + Paginas + ",cd_status=2,passo=passoant where" + " apensado='" + Protocolo + "'", Conexao);
 
/* 1084 */         AjustaApensamentos(Protocolo, Conexao);
/* 1085 */         return 1;
       }
/* 1087 */       return 0;
     } catch (SQLException e) {
     }
/* 1090 */     return 0;
   }
 
   public static int Apensar(String Pt, String Ap, String Usu, String St, Connection Conexao)
   {
/* 1096 */     if (Pt.equals(Ap)) return 0; try
     {
/* 1098 */       boolean Resp = Responsavel(St, Pt, Conexao);
/* 1099 */       if (Resp) {
/* 1100 */         ResultSet rs = null;
/* 1101 */         if (Ap.equals("")) {
/* 1102 */           rs = Consulta("select apensado,paginas from Tb_Processo where protocolo='" + Pt + "'", Conexao);
/* 1103 */           rs.next();
/* 1104 */           if ((EhProcesso(rs.getString(1), Conexao)) && (!EhProcesso(Pt, Conexao))) {
/* 1105 */             Operacao("update tb_processo set paginas=paginas-" + rs.getString(2) + " where protocolo='" + rs.getString(1) + "'", Conexao);
           }
/* 1107 */           Operacao("update tb_processo set Apensado=null,cd_apensador=null,dt_apensamento=null where protocolo='" + Pt + "'", Conexao);
/* 1108 */           if ((EhProcesso(rs.getString(1), Conexao)) && (!EhProcesso(Pt, Conexao)))
/* 1109 */             Operacao("insert into tb_log(protocolo,dt_acao,cd_colaborador,cd_acao) values('" + Pt + "',getdate()," + Usu + ",13)", Conexao);
           else
/* 1111 */             Operacao("insert into tb_log(protocolo,dt_acao,cd_colaborador,cd_acao) values('" + Pt + "',getdate()," + Usu + ",2)", Conexao);
         }
         else {
/* 1114 */           if ((EhProcesso(Ap, Conexao)) && (!EhProcesso(Pt, Conexao))) {
/* 1115 */             rs = Consulta("select paginas from Tb_Processo where protocolo='" + Pt + "'", Conexao);
/* 1116 */             rs.next();
/* 1117 */             Operacao("update tb_processo set paginas=paginas+" + rs.getString(1) + " where protocolo='" + Ap + "'", Conexao);
           }
/* 1119 */           rs = Consulta("select cd_coresponsavel,cd_classificacao from Tb_Processo where protocolo='" + Ap + "'", Conexao);
/* 1120 */           rs.next();
/* 1121 */           Operacao("update tb_processo set Apensado=" + Ap + ",cd_apensador=" + Usu + ",cd_coresponsavel=" + rs.getString("cd_coresponsavel") + ",cd_classificacao=" + rs.getString("cd_classificacao") + ",dt_apensamento=getdate() where protocolo='" + Pt + "'", Conexao);
 
/* 1123 */           if ((EhProcesso(Ap, Conexao)) && (!EhProcesso(Pt, Conexao)))
/* 1124 */             Operacao("insert into tb_log(protocolo,dt_acao,cd_colaborador,cd_acao) values('" + Pt + "',getdate()," + Usu + ",12)", Conexao);
           else {
/* 1126 */             Operacao("insert into tb_log(protocolo,dt_acao,cd_colaborador,cd_acao) values('" + Pt + "',getdate()," + Usu + ",5)", Conexao);
           }
/* 1128 */           rs.close();
         }
/* 1130 */         Acao_Parecer(Pt, "", "", Conexao);
/* 1131 */         Avisar_fav(Pt, Usu, "apensamento ou desapensamento", Conexao);
/* 1132 */         return 1;
       }
/* 1134 */       return 0;
     } catch (SQLException e) {
     }
/* 1137 */     return 0;
   }
 
   public static int Avisar_fav(String Pt, String Cd_Origem, String Acao, Connection Conexao)
   {
     try
     {
/* 1145 */       String Origem = RecLogin(Cd_Origem, Conexao);
/* 1146 */       ResultSet rs = Consulta("SELECT Tb_Favaut.Cd_Colaborador FROM Tb_Favitens INNER JOIN Tb_Favaut ON Tb_Favitens.Cd_Favorito=Tb_Favaut.Cd_Favorito INNER JOIN Tb_Favorito ON Tb_Favitens.Cd_Favorito=Tb_Favorito.Cd_Favorito AND Tb_Favaut.Cd_Favorito = Tb_Favorito.Cd_Favorito WHERE Tb_Favaut.Aviso=1 AND Tb_Favitens.Protocolo='" + Pt + "' UNION SELECT Tb_Favorito.Cd_Proprietario FROM Tb_Favitens INNER JOIN Tb_Favorito ON Tb_Favi" + "tens.Cd_Favorito=Tb_Favorito.Cd_Favorito WHERE Tb_Favorito.Aviso=1 AND Tb_Favitens.Protocolo='" + Pt + "'", Conexao);
 
/* 1152 */       while (rs.next()) {
/* 1153 */         String Destino = RecLogin(rs.getString(1), Conexao);
/* 1154 */         if (!Origem.equals(Destino)) {
/* 1155 */           Operacao("insert into bd_pendencia.dbo.tb_pendencia(origem_pendencia,destino_pendencia,des_pendencia,txt_pendencia,dt_pendencia,status_pendencia,tipo_pendencia) values('" + Origem + "','" + Destino + "','AVISO','Houve " + Acao + " no processo " + Protoc(Pt) + ". Voce esta recebendo esse aviso por ter o processo/documento nos seus favoritos do <a href=http://200.187.19.67/" + "sisproc target=_new>SISPROC</a>. Se nao quiser mais receber avisos, remova-o dos favoritos.',getdate(),1,2)", Conexao);
         }
 
       }
 
/* 1161 */       return 1; } catch (SQLException e) {
     }
/* 1163 */     return 0;
   }
 
   public static String RecLogin(String Cod, Connection Conexao)
   {
     try
     {
/* 1170 */       ResultSet rs = Consulta("select tx_login from tb_colaborador where cod_colaborador='" + Cod + "'", Conexao);
/* 1171 */       rs.next();
/* 1172 */       return rs.getString("tx_login").toUpperCase(); } catch (SQLException e) {
     }
/* 1174 */     return "";
   }
 
   public static int RemProcessoTrilho(String Protocolo, Connection Conexao)
   {
     try
     {
/* 1181 */       Operacao("update tb_processo set cd_trilho=0 where protocolo=" + Protocolo, Conexao);
/* 1182 */       return 1; } catch (SQLException e) {
     }
/* 1184 */     return 0;
   }
 
   public static int Cad_PublicoAlvo(int Inst, String[] Vt, Connection Conexao)
   {
     try
     {
/* 1191 */       Operacao("delete from Tb_instituicaoxpublicoalvo where Cd_Instituicao=" + Inst, Conexao);
/* 1192 */       if (Vt != null) {
/* 1193 */         for (int i = 0; i < Vt.length; i++) {
/* 1194 */           Operacao("insert into Tb_instituicaoXpublicoalvo(cd_instituicao,cd_publicoalvo) values(" + Inst + "," + Vt[i] + ")", Conexao);
         }
       }
/* 1197 */       return 1; } catch (SQLException e) {
     }
/* 1199 */     return 0;
   }
 
   public static int Cad_Relatorio(String Usu, String SQL, Connection Conexao)
   {
/* 1205 */     SQL = SQL.replaceAll("'", "*");
     try {
/* 1207 */       Operacao("delete from Tb_Relatorios where (DATEDIFF(d, Dt_Relatorio, GETDATE()) > 1) AND (Salvo = 0)", Conexao);
/* 1208 */       Operacao("insert into tb_relatorios(Cd_Colaborador,Dt_Relatorio,Ds_Consulta,Salvo) values(" + Usu + ",getdate(),'" + SQL + "',0)", Conexao);
 
/* 1210 */       ResultSet rs = Consulta("select max(cd_relatorio) as codmax from tb_relatorios where cd_colaborador=" + Usu, Conexao);
/* 1211 */       rs.next();
/* 1212 */       return rs.getInt("codmax"); } catch (SQLException e) {
     }
/* 1214 */     return 0;
   }
 
   public static int Cad_Instituicao(String Nm, String Ab, String Tp, String At, String Av, String TpL, String End, String Num, String Cpm, String Mun, String Cep, String Cnpj, String Cnas, String UpM, String UpE, String UpF, String Ctt, String Tl1, String Tl2, String Fx, String Eml, String Usu, String Cg, Connection Conexao)
   {
     try
     {
/* 1224 */       ResultSet rs = null;
/* 1225 */       if (!Cnpj.equals("null")) {
/* 1226 */         rs = Consulta("select cnpj from tb_instituicao where cnpj=" + Cnpj, Conexao);
/* 1227 */         if (rs.next()) return 0;
       }
/* 1229 */       Operacao("insert into tb_instituicao(ds_instituicao,ds_abreviacao,cd_tipoinst,cd_areaatuacao,orgao,cd_tipologradouro,end_logradouro,end_numero,end_complemento,cd_municipio,end_cep,cnpj,num_reg_conselho,Num_UP_Municipal,Num_UP_Estadual,Num_UP_Federal,Nm_Contato,Telefone_1,Telefone_2,Fax,E_Mail,Dt_Cadastramento,cd_colaborador,cargo_contato) values('" + Nm + "'," + Ab + "," + Tp + "," + At + "," + Av + "," + TpL + "," + End + "," + Num + "," + Cpm + "," + Mun + "," + Cep + "," + Cnpj + "," + Cnas + "," + UpM + "," + UpE + "," + UpF + "," + Ctt + "," + Tl1 + "," + Tl2 + "," + Fx + "," + Eml + ",getdate()," + Usu + "," + Cg + ")", Conexao);
 
/* 1235 */       rs = Consulta("select max(cd_instituicao) as codmax from tb_instituicao", Conexao);
/* 1236 */       rs.next();
/* 1237 */       return rs.getInt("codmax"); } catch (SQLException e) {
     }
/* 1239 */     return 0;
   }
 
   public static int Edt_Instituicao(String Nm, String Ab, String Tp, String At, String TpL, String End, String Num, String Cpm, String Mun, String Cep, String Cnpj, String Cnas, String UpM, String UpE, String UpF, String Ctt, String Tl1, String Tl2, String Fx, String Eml, String Usu, String Cod, String Cg, Connection Conexao)
   {
     try
     {
/* 1248 */       ResultSet rs = null;
/* 1249 */       if (!Cnpj.equals("null")) {
/* 1250 */         rs = Consulta("select cnpj from tb_instituicao where cd_instituicao<>" + Cod + " and cnpj=" + Cnpj, Conexao);
/* 1251 */         if (rs.next()) return 0;
       }
/* 1253 */       Operacao("update tb_instituicao set ds_instituicao='" + Nm + "',Ds_Abreviacao=" + Ab + ",cd_tipoinst=" + Tp + ",cd_areaatuacao=" + At + ",cd_tipologradouro=" + TpL + ",end_logradouro=" + End + ",end_numero=" + Num + ",end_complemento=" + Cpm + ",cd_municipio=" + Mun + ",end_cep=" + Cep + ",cnpj=" + Cnpj + ",num_reg_conselho=" + Cnas + ",num_up_municipal=" + UpM + ",num_up_estadual=" + UpE + ",num_up_federal=" + UpF + ",nm_contato=" + Ctt + ",telefone_1=" + Tl1 + ",telefone_2=" + Tl2 + ",fax=" + Fx + ",e_mail=" + Eml + ",cd_colaborador=" + Usu + ",cargo_contato=" + Cg + " where cd_instituicao=" + Cod, Conexao);
 
/* 1258 */       return Integer.parseInt(Cod); } catch (SQLException e) {
     }
/* 1260 */     return 0;
   }
 
   public static int Edt_Orgao(String Cod, String Flag, Connection Conexao)
   {
     try
     {
/* 1267 */       Operacao("update tb_instituicao set orgao=" + Flag + " where cd_instituicao=" + Cod, Conexao);
/* 1268 */       return 1; } catch (SQLException e) {
     }
/* 1270 */     return 0;
   }
 
   public static int Edt_Orgao(String[] Vetor, Connection Conexao)
   {
     try
     {
/* 1277 */       Operacao("update tb_instituicao set orgao=0 where orgao=1", Conexao);
/* 1278 */       for (int i = 0; i < Vetor.length; i++) {
/* 1279 */         Operacao("update Tb_instituicao set orgao=1 where cd_instituicao=" + Vetor[i], Conexao);
       }
/* 1281 */       return 1; } catch (SQLException e) {
     }
/* 1283 */     return 0;
   }
 
   public static String Formatadata(String Databruta)
   {
/* 1289 */     if (Databruta.substring(10).equals(" 00:00:00.0")) {
/* 1290 */       return Databruta.substring(8, 10) + "/" + Databruta.substring(5, 7) + "/" + Databruta.substring(2, 4);
     }
/* 1292 */     return Databruta.substring(8, 10) + "/" + Databruta.substring(5, 7) + "/" + Databruta.substring(2, 4) + Databruta.substring(10, 16);
   }
 
   public static String Protoc(String Protocolo)
   {
/* 1298 */     if (Protocolo.length() == 15) {
/* 1299 */       return Protocolo.substring(0, 13);
     }
/* 1301 */     return Protocolo;
   }
 
   public static String Duplic(String Protocolo)
   {
/* 1307 */     if (Protocolo.length() == 15) {
/* 1308 */       return Protocolo.substring(13, 15);
     }
/* 1310 */     return "00";
   }
 
   public static String Formatadatapesquisa(String Databruta)
   {
/* 1316 */     return Databruta.substring(6, 10) + Databruta.substring(3, 5) + Databruta.substring(0, 2);
   }
 
   public static String Permanencia(int Minutos)
   {
/* 1322 */     int dias = Minutos / 1440;
/* 1323 */     Minutos %= 1440;
/* 1324 */     int horas = Minutos / 60;
/* 1325 */     Minutos %= 60;
/* 1326 */     return dias + " d " + horas + " h " + Minutos + " m ";
   }
 
   public static boolean ExisteApensado(String Protocolo, boolean Tudo, Connection Conexao)
     throws SQLException
   {
     ResultSet rs;
    
/* 1332 */     if (Tudo)
/* 1333 */       rs = Consulta("select protocolo from tb_processo where apensado='" + Protocolo + "'", Conexao);
     else {
/* 1335 */       rs = Consulta("select protocolo from tb_processo where apensado='" + Protocolo + "' and (len(protocolo) = 15)", Conexao);
     }
/* 1337 */     return rs.next();
   }
 
   public static String GeraCodGuia(String Tabela, Connection Conexao) throws SQLException
   {
/* 1342 */     boolean exit = false;
/* 1343 */     double x = 0.0D;
/* 1344 */     ResultSet rs = null;
/* 1345 */     while (!exit) {
/* 1346 */       x = Math.random();
/* 1347 */       x *= 10000.0D;
/* 1348 */       rs = Consulta("select cd_guia from " + Tabela + " where cd_guia=" + String.valueOf((int)x), Conexao);
/* 1349 */       if (!rs.next()) exit = true;
     }
/* 1351 */     return String.valueOf((int)x);
   }
 
   public static String Responsavel(String Protocolo, Connection Conexao) throws SQLException
   {
/* 1356 */     ResultSet rs = Consulta("select cd_responsavel from tb_processo where protocolo='" + Protocolo + "'", Conexao);
/* 1357 */     rs.next();
/* 1358 */     if (rs.getString("cd_responsavel") == null) {
/* 1359 */       return "";
     }
/* 1361 */     return rs.getString("cd_responsavel");
   }
 
   public static boolean Responsavel(String Cod_setor, String Protocolo, Connection Conexao)
     throws SQLException
   {
/* 1367 */     if (Cod_setor == null) return false;
/* 1368 */     ResultSet rs = Consulta("select protocolo from tb_processo where protocolo='" + Protocolo + "' and cd_responsavel=" + Cod_setor, Conexao);
/* 1369 */     if (rs.next()) {
/* 1370 */       return true;
     }
/* 1372 */     return false;
   }
 
   public static String Coresponsavel(String Protocolo, Connection Conexao)
     throws SQLException
   {
/* 1378 */     ResultSet rs = Consulta("select cd_coresponsavel from tb_processo where protocolo='" + Protocolo + "'", Conexao);
/* 1379 */     rs.next();
/* 1380 */     if (rs.getString("cd_coresponsavel") == null) {
/* 1381 */       return "0";
     }
 
/* 1384 */     return rs.getString("cd_coresponsavel");
   }

   public static String Designador(String Protocolo, Connection Conexao)
     throws SQLException
   {
/* 1390 */     ResultSet rs = Consulta("select cd_designador from tb_processo where protocolo='" + Protocolo + "'", Conexao);
/* 1391 */     rs.next();
/* 1392 */     if (rs.getString("cd_designador") == null) {
/* 1393 */       return "";
     }
/* 1395 */     return rs.getString("cd_designador");
   }
 
   public static boolean Coresponsavel(String Cod_colaborador, String Protocolo, Connection Conexao)
     throws SQLException
   {
/* 1401 */     if (Cod_colaborador == null) return false;
/* 1402 */     ResultSet rs = Consulta("select protocolo from tb_processo where protocolo='" + Protocolo + "' and cd_coresponsavel=" + Cod_colaborador, Conexao);
/* 1403 */     if (rs.next()) {
/* 1404 */       return true;
     }
/* 1406 */     return false;
   }
 
   public static boolean Designador(String Cod_colaborador, String Protocolo, Connection Conexao)
     throws SQLException
   {
/* 1412 */     if (Cod_colaborador == null) return false;
/* 1413 */     ResultSet rs = Consulta("select protocolo from tb_processo where protocolo='" + Protocolo + "' and cd_designador=" + Cod_colaborador, Conexao);
/* 1414 */     if (rs.next()) {
/* 1415 */       return true;
     }
/* 1417 */     return false;
   }
 
   public static String Digitador(String Protocolo, Connection Conexao)
     throws SQLException
   {
/* 1423 */     ResultSet rs = Consulta("select cd_digitador from tb_processo where protocolo='" + Protocolo + "'", Conexao);
/* 1424 */     rs.next();
/* 1425 */     if (rs.getString("cd_digitador") == null) {
/* 1426 */       return "";
     }
/* 1428 */     return rs.getString("cd_digitador");
   }
 
   public static boolean Digitador(String Cod_colaborador, String Protocolo, Connection Conexao)
     throws SQLException
   {
/* 1434 */     if (Cod_colaborador == null) return false;
/* 1435 */     ResultSet rs = Consulta("select protocolo from tb_processo where protocolo='" + Protocolo + "' and cd_digitador=" + Cod_colaborador, Conexao);
/* 1436 */     if (rs.next()) {
/* 1437 */       return true;
     }
/* 1439 */     return false;
   }
 }

/* Location:           C:\apache-tomcat-6.0.35\webapps\sisproc\WEB-INF\classes\
 * Qualified Name:     opbanco.Banco
 * JD-Core Version:    0.6.2
 */